package com.dmcliver.timetracker.session;

import java.io.Serializable;
import java.util.List;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.security.Credentials;

import com.dmcliver.timetracker.entity.Person;
import com.dmcliver.timetracker.persistence.PersonDAO;

@Name("personBean")
public class PersonBean implements Serializable{

	private static final long serialVersionUID = -89486604723815120L;

	@In
	private PersonDAO personDAO;
	
	@In
	private Credentials credentials;
	
	private List<Person> ppl;
	
	public List<Person> getPeople(){
		
		personDAO.getAllPeopleWithFirstnameToday(getUsername());
		
		if(ppl == null)
			ppl = personDAO.findAll();
		return ppl;
	}
	
	public String getUsername(){
		
		return credentials.getUsername();
	}
}
